function [RMSD] = RMSD(data,model,components2use,normon)

    data =  data(:,components2use); 
    model = model(:,components2use); 
    
    if strcmp(normon,'NormalizeComponents')==1
      data=bsxfun(@rdivide,data,nansum(data,2));
      model=bsxfun(@rdivide,model,nansum(model,2));
    end
    
    
  RMSD = sqrt(nansum((data-model).^2, 2)./size(components2use,2));
       
  
  
end

